package vn.lumi.smarthome.ulti;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

public class Preference {
private static final String PREFERENCES_NAME="prefers_smarthome";
	
	@SuppressLint("CommitPrefEdits")
	private static SharedPreferences.Editor getEditor(Context context)
	{
		SharedPreferences sharedPreferences=context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
		SharedPreferences.Editor editor=sharedPreferences.edit();
		return editor;
	}
	private static SharedPreferences getPreferences(Context context)
	{
		return context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
	}
	
	public static void saveRemember(Context context,boolean value){
		getEditor(context).putBoolean("isRemember", value).commit();
	}
	public static boolean isRemember(Context context){
		return getPreferences(context).getBoolean("isRemember", false);
	}
	public static void saveUID(Context context,String uid){
		getEditor(context).putString("uid", uid).commit();
	}
	public static String getUID(Context context){
		return getPreferences(context).getString("uid", null);
	}
	public static void savepwd(Context context,String pwd){
		getEditor(context).putString("pwd", pwd).commit();
	}
	public static String getPWD(Context context){
		return getPreferences(context).getString("pwd", null);
	}
}
